<template>
  <div>
    <div class="m_comingTitle" v-if="m_item.comingTitle">12月20日 周四</div>
    <div class="movieItem" v-longpress="showActionMenu" @click="getDetail">
      <div class="left">
        <img @click.stop="showImage" v-lazy="m_item.img.replace('w.h','128.180')" />
      </div>
      <ul class="center">
        <li class="nm">{{m_item.nm}}</li>
        <li class="sc" v-if="m_item.globalReleased==true">
          评分：
          <span>{{m_item.sc}}</span>
        </li>
        <li class="sc" v-if="m_item.globalReleased==false">
          <span>{{m_item.wish}}</span>人想看
        </li>
        <li>{{m_item.star}}</li>
        <li>{{m_item.showInfo}}</li>
      </ul>
      <div class="right">
        <button
          type="button"
          class="btnBuy"
          v-if="m_item.globalReleased==true"
          @click.stop="buyTicket"
        >购票</button>
        <button type="button" class="btnPre" v-else>预售</button>
      </div>
    </div>
  </div>
</template>
<script>
import { mapActions } from "vuex";
import { log } from "util";
export default {
  name: "MovieItem",
  props: ["m_item", "m_index"],
  data() {
    return {};
  },
  methods: {
    ...mapActions(["showPreviewImage", "showActionSheet"]),
    showImage() {
      //预览图片了    自已不处理，交给外边去处理
      //触发了外边的事件
      this.$emit("showImage", this.m_index);
    },
    showActionMenu() {
      this.showActionSheet({
        itemList: ["添加收藏", "查看详细"],
        success: function(index) {
          //假设我点了上面的菜以后，我应该在这里处理事情
          if (index == 0) {
            console.log("你要添加收藏");
          } else if (index == 1) {
            console.log("你要查看详细");
          }
        }
      });
    },
    buyTicket() {
      // this.$toast("我是轻消息提示，会自己消失");
      //this.$alert("我在提示你");这是简写的方法
      /*
      this.$alert({
        content:"我在提示你",
        title:"这是标题"
      }).then(()=>{
        console.log("这是回调方法，代表点击确认以后执行的事件")
      });
      */
      /*
     this.$confirm({
       title:"标哥提示",
       content:"你确定要买票吗?"
     })*/

      this.$confirm("你确定要买票吗？")
        .then(() => {
          console.log("你点了确定");
        })
        .catch(() => {
          console.log("你点了取消");
        });
    },
    getDetail() {
      this.$router.push({
        name: "Detail",
        query: {
          id: this.m_item.id
        }
      });
    }
  }
};
</script>
<style lang="scss" scoped>
.movieItem {
  display: flex;
  font-size: 14px;
  box-sizing: border-box;
  padding: 0.06rem;
  border-bottom: 1px solid #ececec;
  .left {
    width: 1.8rem;
    img {
      width: 100%;
      display: block;
    }
  }
  .center {
    margin: 0;
    padding: 0;
    list-style-type: none;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    color: gray;
    margin-left: 0.06rem;
    .nm {
      font-size: 0.4rem;
      font-weight: bold;
      color: black;
    }
    .sc {
      > span {
        color: orange;
        font-size: 0.4rem;
      }
    }
  }
  .right {
    width: 1.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    .btnBuy {
      width: 1.2rem;
      border: none;
      height: 0.65rem;
      background-color: #e54847;
      color: white;
      border-radius: 0.1rem;
      outline: none;
    }
    .btnPre {
      @extend .btnBuy;
      background-color: #3c9fe6;
    }
  }
}
.m_comingTitle{
  font-size: .36rem;
  margin: .08rem;
  color: gray;
}
</style>